**翻译状态：** 本文是英文页面 [Install on WSL](/index.php/Install_on_WSL "Install on WSL") 的[翻译](/index.php/ArchWiki_Translation_Team_(%E7%AE%80%E4%BD%93%E4%B8%AD%E6%96%87) "ArchWiki Translation Team (简体中文)")，最后翻译时间：2017-11-05，点击[这里](https://wiki.archlinux.org/index.php?title=Install+on+WSL&diff=0&oldid=494812)可以查看翻译后英文页面的改动。

Windows 10 包含一个模拟 Linux 内核的子系统，使得 windows 可以运行 Linux 原生应用程序。这个子系统有点像反过来的 [Wine](/index.php/Wine "Wine")，但是它比 Wine 更加底层。默认情况下，此子系统使用 Ubuntu 用户空间，但是它可以被替换成 Arch。你需要使用一个现有的 Arch 安装去构建一些软件包，这篇说明基于[这篇教程](https://www.reddit.com/r/bashonubuntuonwindows/comments/5vnne8/howto_installing_arch_on_wsl_manually/)。

## 准备

**注意:** 如果你在2017年秋季的创造者更新前已经使用WSL，首先从命令提示符卸载它（你可能需要先保存一些数据）：
```
> lxrun /uninstall /full /y

```

如果你还没有使用过 Linux 子系统，请按照[官方安装指南](https://msdn.microsoft.com/en-gb/commandline/wsl/install_guide)进行安装。简单来说，需要启用位于 *启用或关闭 Windows 功能* 的适用于 Linux 的 Windows 子系统。

安装 Windows 10 2017 年秋季创造者更新，这个版本解决了之前的一些问题，建议所有 WSL 都基于这个版本进行安装。

## 安装

在[Windows 应用商店](https://www.microsoft.com/en-us/store/p/ubuntu/9nblggh4msv6)安装 Ubuntu。

确保默认用户为 root:

```
> ubuntu config --default-user root

```

从开始菜单打开 Ubuntu。

从 [Arch Linux Downloads](https://www.archlinux.org/download/) 下载 Arch bootstrap .tar.gz 然后解压：

```
$ tar -zxvf /mnt/c/Users/*username*/Downloads/archlinux-bootstrap-2017.06.01-x86_64.tar.gz

```

在 `~/root.x86_64/etc/pacman.d/mirrorlist` 文件中，选择需要的服务器，取消注释。

让 WSL 自动生成 `/etc/resolv.conf`：

```
$ echo "# This file was automatically generated by WSL. To stop automatic generation of this file, remove this line." > ~/root.x86_64/etc/resolv.conf

```

退出所有打开的 Bash 命令行窗口。

在 Windows 资源管理器中打开 `%localappdata%\Packages`，并找到 `CanonicalGroupLimited.UbuntuonWindows_*` （其中， `*` 表示随机字符串 ）。在 `%localappdata%\Packages\CanonicalGroupLimited.UbuntuonWindows_*\LocalState\rootfs` 中删除 `bin`, `etc`, `lib`, `lib64`, `sbin`, `usr` and `var`.

然后从`rootfs\root\root.x86_64`移动(不要复制)相同的文件到 `rootfs`

使用一台 Linux 电脑构建 [fakeroot-tcp](https://aur.archlinux.org/packages/fakeroot-tcp/), 然后复制到 Windows 电脑。在 System V IPC 被完全实现之前 *fakeroot-tcp* 都是必需的。 （[(详情请见)](https://github.com/Microsoft/BashOnWindows/issues/2465)。

之前的 Win10 版本需要安装 *glibc-wsl* 以解决 [这个bug](https://github.com/Microsoft/BashOnWindows/issues/1878)，[17046后已此问题已经被修复](https://github.com/Microsoft/WSL/issues/1878#issuecomment-350322200)，因此不再需要。

再次打开Bash，开始安装Arch：

```
# pacman-key --init
# pacman-key --populate archlinux
# pacman -U /mnt/c/Users/*username*/Downloads/fakeroot-tcp-1.21-2-x86_64.pkg.tar.xz
# pacman -Syyu base base-devel

```

设置用户 (不需要和 Windows 用户名相同)：

```
# useradd -m -G wheel -s /bin/bash *username*
# passwd root
# passwd *username*

```

设置此用户为默认用户

```
> ubuntu config --default-user username

```